package org.pblue.appengine.data.caching;

import java.io.Serializable;
import java.util.Set;

import javax.jdo.annotations.NotPersistent;


@SuppressWarnings("serial")
public class CacheBean implements Serializable, Cacheable {

  @NotPersistent
  private Object mCacheKey;
  
  public Object getCacheKey() {
    return this.mCacheKey;
  }

  public void setCacheKey(Object pCacheKey) {
    this.mCacheKey = pCacheKey;
  }
  
  @NotPersistent
  private Set<Object> mDependencies;
  
  public Set<Object> getDependencies() {
    return this.mDependencies;
  }

  public void setDependencies(Set<Object> pDependencies) {
    this.mDependencies = pDependencies;
  }
  
  public void addDependency(Cacheable dependency) {
    this.mDependencies.add(dependency.getCacheKey());
    if (Cache.cache().containsKey(this.getCacheKey())) {
      Cache.add(this);
    }
  }
  
}
